package cn.kevenpotter.leetcode.easy.e155;

import java.util.Deque;
import java.util.LinkedList;

public class MinStack {

    Deque<Integer> rawStack;
    Deque<Integer> minStack;

    public MinStack() {
        rawStack = new LinkedList<Integer>();
        minStack = new LinkedList<Integer>();
        minStack.push(Integer.MAX_VALUE);
    }

    public void push(int val) {
        rawStack.push(val);
        minStack.push(Math.min(val, minStack.peek()));
    }

    public void pop() {
        rawStack.pop();
        minStack.pop();
    }

    public int top() {
        return rawStack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }
}
